{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "5NerV-EQ6f7o"
   },
   "source": [
    "<center>\n",
    "<p style=\"text-align:center\">\n",
    "<img alt=\"phoenix logo\" src=\"https://raw.githubusercontent.com/Arize-ai/phoenix-assets/9e6101d95936f4bd4d390efc9ce646dc6937fb2d/images/socal/github-large-banner-phoenix.jpg\" width=\"1000\"/>\n",
    "<br>\n",
    "<br>\n",
    "<a href=\"https://arize.com/docs/phoenix/\">Docs</a>\n",
    "|\n",
    "<a href=\"https://github.com/Arize-ai/phoenix\">GitHub</a>\n",
    "|\n",
    "<a href=\"https://arize-ai.slack.com/join/shared_invite/zt-11t1vbu4x-xkBIHmOREQnYnYDH1GDfCg?__hstc=259489365.a667dfafcfa0169c8aee4178d115dc81.1733501603539.1733501603539.1733501603539.1&__hssc=259489365.1.1733501603539&__hsfp=3822854628&submissionGuid=381a0676-8f38-437b-96f2-fc10875658df#/shared-invite/email\">Community</a>\n",
    "</p>\n",
    "</center>\n",
    "<h1 align=\"center\">Chain-of-Thought Prompting Tutorial</h1>\n",
    "\n",
    "LLMs excel at text generation, but their reasoning abilities depend on how we prompt them. **Chain of Thought (CoT)** prompting enhances logical reasoning by guiding the model to think step by step, improving accuracy in tasks like math, logic, and multi-step problem solving.\n",
    "\n",
    "In this tutorial, you will:\n",
    "- Examine how different prompting techniques influence reasoning by evaluating model performance on a dataset.\n",
    "- Refine prompting strategies, progressing from basic approaches to structured reasoning.\n",
    "- Utilize Phoenix to assess accuracy at each stage and explore the model's thought process.\n",
    "- Learn how to apply CoT prompting effectively in real-world tasks.\n",
    "\n",
    "⚠️ You'll need an OpenAI Key for this tutorial.\n",
    "\n",
    "Let’s dive in! 🚀"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "gdBXRIXsBmHf"
   },
   "source": [
    "# **Set up Dependencies and Keys**\n",
    "\n",
    "> Add blockquote\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install -qqqq arize-phoenix-client datasets openinference-instrumentation-openai"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "VCTqznVnBsdy"
   },
   "source": [
    "Next you need to connect to Phoenix. The code below will connect you to a Phoenix Cloud instance. You can also [connect to a self-hosted Phoenix instance](https://arize.com/docs/phoenix/deployment) if you'd prefer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from getpass import getpass\n",
    "\n",
    "if not os.environ.get(\"PHOENIX_COLLECTOR_ENDPOINT\"):\n",
    "    os.environ[\"PHOENIX_COLLECTOR_ENDPOINT\"] = input(\n",
    "        \"Enter your Phoenix collector endpoint (e.g. https://app.phoenix.arize.com/s/example): \"\n",
    "    )\n",
    "if not os.environ.get(\"PHOENIX_API_KEY\"):\n",
    "    os.environ[\"PHOENIX_API_KEY\"] = getpass(\"Enter your Phoenix API key: \")\n",
    "\n",
    "if not os.environ.get(\"OPENAI_API_KEY\"):\n",
    "    os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API key: \")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "4q4McBGHBolG"
   },
   "source": [
    "# **Load Dataset Into Phoenix**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "t43xN6j2CYyM"
   },
   "source": [
    "This dataset includes math word problems, step-by-step explanations, and their corresponding answers. As we refine our prompt, we'll test it against the dataset to measure and track improvements in performance.\n",
    "\n",
    "Here, we also import the Phoenix Client, which enables us to create and modify prompts directly within the notebook while seamlessly syncing changes to the Phoenix UI."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import uuid\n",
    "\n",
    "from datasets import load_dataset\n",
    "\n",
    "from phoenix.client import Client as PhoenixClient\n",
    "\n",
    "ds = load_dataset(\"syeddula/math_word_problems\")[\"train\"]\n",
    "ds = ds.to_pandas()\n",
    "ds.head()\n",
    "\n",
    "unique_id = uuid.uuid4()\n",
    "\n",
    "# Upload the dataset to Phoenix\n",
    "dataset = PhoenixClient().datasets.create_dataset(\n",
    "    dataframe=ds,\n",
    "    input_keys=[\"Word Problem\"],\n",
    "    output_keys=[\"Answer\"],\n",
    "    name=f\"wordproblems-{unique_id}\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Ezhxr0y4sr2c"
   },
   "source": [
    "# **Zero-Shot Prompting** - Baseline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "K-O8zMB6CwsY"
   },
   "source": [
    "**Zero-shot prompting** is the simplest way to interact with a language model—it involves asking a question without providing any examples or reasoning steps. The model generates an answer based solely on its pre-trained knowledge.\n",
    "\n",
    "This serves as our baseline for comparison. By evaluating its performance on our dataset, we can see how well the model solves math word problems without explicit guidance. In later sections, we’ll introduce structured reasoning techniques like **Chain of Thought (CoT)** to measure improvements in accuracy and answers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from openai import OpenAI\n",
    "from openai.types.chat.completion_create_params import CompletionCreateParamsBase\n",
    "\n",
    "from phoenix.client.types import PromptVersion\n",
    "\n",
    "params = CompletionCreateParamsBase(\n",
    "    model=\"gpt-3.5-turbo\",\n",
    "    temperature=0,\n",
    "    messages=[\n",
    "        {\n",
    "            \"role\": \"system\",\n",
    "            \"content\": \"You are an evaluator who outputs the answer to a math word problem. Only respond with the integer answer. Be sure not include words, explanations, symbols, labels, or units and round all decimals answers.\",\n",
    "        },\n",
    "        {\"role\": \"user\", \"content\": \"{{Problem}}\"},\n",
    "    ],\n",
    ")\n",
    "\n",
    "prompt_identifier = \"wordproblems\"\n",
    "\n",
    "prompt = PhoenixClient().prompts.create(\n",
    "    name=prompt_identifier,\n",
    "    prompt_description=\"A prompt for computing answers to word problems.\",\n",
    "    version=PromptVersion.from_openai(params),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "02qv5oPfw8bB"
   },
   "source": [
    "At this stage, this initial prompt is now available in Phoenix under the Prompt tab. Any modifications made to the prompt moving forward will be tracked under **Versions**, allowing you to monitor and compare changes over time.\n",
    "\n",
    "Prompts in Phoenix store more than just text—they also include key details such as the prompt template, model configurations, and response format, ensuring a structured and consistent approach to generating outputs."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "o_zcjrHZxYMy"
   },
   "source": [
    "![Baseline Prompt in UI](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "lGiOk2d2xpCH"
   },
   "source": [
    "Next, we will define a task and evaluator for the experiment. Then, we run our experiment.\n",
    "\n",
    "Because our dataset has ground truth labels, we can use a simple function to extract the answer and check if the calculated answer matches the expected output."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from phoenix.client import AsyncClient\n",
    "\n",
    "\n",
    "def zero_shot_prompt(input):\n",
    "    client = OpenAI()\n",
    "    resp = client.chat.completions.create(\n",
    "        **prompt.format(variables={\"Problem\": input[\"Word Problem\"]})\n",
    "    )\n",
    "    return resp.choices[0].message.content.strip()\n",
    "\n",
    "\n",
    "def evaluate_response(output, expected):\n",
    "    if not output.isdigit():\n",
    "        return False\n",
    "    return int(output) == int(expected[\"Answer\"])\n",
    "\n",
    "\n",
    "async_client = AsyncClient()\n",
    "initial_experiment = await async_client.experiments.run_experiment(\n",
    "    dataset=dataset,\n",
    "    task=zero_shot_prompt,\n",
    "    evaluators=[evaluate_response],\n",
    "    experiment_description=\"Zero-Shot Prompt\",\n",
    "    experiment_name=\"zero-shot-prompt\",\n",
    "    experiment_metadata={\"prompt\": \"prompt_id=\" + prompt.id},\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "GsKV_KjxyThE"
   },
   "source": [
    "We can review the results of the experiment in Phoenix. We achieved ~75% accuracy in this run. In the following sections, we will iterate on this prompt and see how our evaluation changes!\n",
    "\n",
    "\n",
    "**Note**: Throughout this tutorial, you will encounter various evaluator outcomes. At times, you may notice a decline in performance compared to the initial experiment. However, this is not necessarily a flaw. Variations in results can arise due to factors such as the choice of LLM, inherent model behaviors, and randomness.\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "1PazGexazLiR"
   },
   "source": [
    "![Baseline Experiement](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_2.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "dbgdg0Axj0t2"
   },
   "source": [
    "# **Zero-Shot CoT Prompting**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "uYt0hGZCDIps"
   },
   "source": [
    "Zero-shot prompting provides a direct answer, but it often struggles with complex reasoning. **Zero-Shot Chain of Thought (CoT)** prompting improves this by explicitly instructing the model to think step by step before arriving at a final answer.\n",
    "\n",
    "By adding a simple instruction like *“Let’s think through this step by step,”* we encourage the model to break down the problem logically. This structured reasoning can lead to more accurate answers, especially for multi-step math problems.\n",
    "\n",
    "In this section, we'll compare Zero-Shot CoT against our baseline to evaluate its impact on performance. First, let's create the prompt."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "zero_shot_COT_template = \"\"\"\n",
    "You are an evaluator who outputs the answer to a math word problem.\n",
    "\n",
    "You must always think through the problem logically before providing an answer.\n",
    "\n",
    "First, show some of your reasoning.\n",
    "\n",
    "Then output the integer answer ONLY on a final new line. In this final answer, be sure not include words, commas, labels, or units and round all decimals answers.\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "params = CompletionCreateParamsBase(\n",
    "    model=\"gpt-3.5-turbo\",\n",
    "    temperature=0,\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": zero_shot_COT_template},\n",
    "        {\"role\": \"user\", \"content\": \"{{Problem}}\"},\n",
    "    ],\n",
    ")\n",
    "\n",
    "zero_shot_COT = PhoenixClient().prompts.create(\n",
    "    name=prompt_identifier,\n",
    "    prompt_description=\"Zero Shot COT prompt\",\n",
    "    version=PromptVersion.from_openai(params),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nwpgXn9-wbMT"
   },
   "source": [
    "This updated prompt is now lives in Phoenix as a new prompt version.\n",
    "\n",
    "Next, we run our task and evaluation by extracting the answer from the output of our LLM."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "\n",
    "\n",
    "def zero_shot_COT_prompt(input):\n",
    "    client = OpenAI()\n",
    "    resp = client.chat.completions.create(\n",
    "        **zero_shot_COT.format(variables={\"Problem\": input[\"Word Problem\"]})\n",
    "    )\n",
    "    response_text = resp.choices[0].message.content.strip()\n",
    "    lines = response_text.split(\"\\n\")\n",
    "    final_answer = lines[-1].strip()\n",
    "    final_answer = re.sub(r\"^\\*\\*(\\d+)\\*\\*$\", r\"\\1\", final_answer)\n",
    "    return {\"full_response\": response_text, \"final_answer\": final_answer}\n",
    "\n",
    "\n",
    "def evaluate_response(output, expected):\n",
    "    final_answer = output[\"final_answer\"]\n",
    "    if not final_answer.isdigit():\n",
    "        return False\n",
    "    return int(final_answer) == int(expected[\"Answer\"])\n",
    "\n",
    "\n",
    "initial_experiment = await async_client.experiments.run_experiment(\n",
    "    dataset=dataset,\n",
    "    task=zero_shot_COT_prompt,\n",
    "    evaluators=[evaluate_response],\n",
    "    experiment_description=\"Zero-Shot COT Prompt\",\n",
    "    experiment_name=\"zero-shot-cot-prompt\",\n",
    "    experiment_metadata={\"prompt\": \"prompt_id=\" + zero_shot_COT.id},\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "f0ElA-dN1ZS_"
   },
   "source": [
    "By clicking into the experiement in Phoenix, you can take a look at the steps the model took the reach the answer. By telling the model to think through the problem and output reasoning, we see a performance improvement."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "-qN6-NCV1TfT"
   },
   "source": [
    "![Experiment Details](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_3.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "WSuMlKhr1lmm"
   },
   "source": [
    "![Experiment 2 Outcome](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_4.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "SaOI16Qz4abX"
   },
   "source": [
    "# **Self-Consistency CoT Prompting**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "rmrltVAZDe2Y"
   },
   "source": [
    "Even with Chain of Thought prompting, a single response may not always be reliable. **Self-Consistency CoT** enhances accuracy by generating multiple reasoning paths and selecting the most common answer. Instead of relying on one response, we sample multiple outputs and aggregate them, reducing errors caused by randomness or flawed reasoning steps.\n",
    "\n",
    "This method improves robustness, especially for complex problems where initial reasoning steps might vary. In this section, we'll compare Self-Consistency CoT to our previous promppts to see how using on multiple responses impacts overall performance.\n",
    "\n",
    "Let's repeat the same process as above with a new prompt and evaluate the outcome."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "consistency_COT_template = \"\"\"\n",
    "\n",
    "You are an evaluator who outputs the answer to a math word problem.\n",
    "\n",
    "Follow these steps:\n",
    "1. Solve the problem **multiple times independently**, thinking through the solution carefully each time.\n",
    "2. Show some of your reasoning for each independent attempt.\n",
    "3. Identify the integer answer that appears most frequently across your attempts.\n",
    "4. On a **new line**, output only this majority answer as a plain integer with **no words, commas, labels, units, or special characters**.\n",
    "\"\"\"\n",
    "\n",
    "params = CompletionCreateParamsBase(\n",
    "    model=\"gpt-3.5-turbo\",\n",
    "    temperature=0,\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": consistency_COT_template},\n",
    "        {\"role\": \"user\", \"content\": \"{{Problem}}\"},\n",
    "    ],\n",
    ")\n",
    "\n",
    "self_consistency_COT = PhoenixClient().prompts.create(\n",
    "    name=prompt_identifier,\n",
    "    prompt_description=\"self consistency COT prompt\",\n",
    "    version=PromptVersion.from_openai(params),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def self_consistency_COT_prompt(input):\n",
    "    client = OpenAI()\n",
    "    resp = client.chat.completions.create(\n",
    "        **self_consistency_COT.format(variables={\"Problem\": input[\"Word Problem\"]})\n",
    "    )\n",
    "    response_text = resp.choices[0].message.content.strip()\n",
    "    lines = response_text.split(\"\\n\")\n",
    "    final_answer = lines[-1].strip()\n",
    "    final_answer = re.sub(r\"^\\*\\*(\\d+)\\*\\*$\", r\"\\1\", final_answer)\n",
    "    return {\"full_response\": response_text, \"final_answer\": final_answer}\n",
    "\n",
    "\n",
    "def evaluate_response(output, expected):\n",
    "    final_answer = output[\"final_answer\"]\n",
    "    if not final_answer.isdigit():\n",
    "        return False\n",
    "    return int(final_answer) == int(expected[\"Answer\"])\n",
    "\n",
    "\n",
    "initial_experiment = await async_client.experiments.run_experiment(\n",
    "    dataset=dataset,\n",
    "    task=self_consistency_COT_prompt,\n",
    "    evaluators=[evaluate_response],\n",
    "    experiment_description=\"Self Consistency COT Prompt\",\n",
    "    experiment_name=\"self-consistency-cot-prompt\",\n",
    "    experiment_metadata={\"prompt\": \"prompt_id=\" + self_consistency_COT.id},\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "T2Kxegsr4MCv"
   },
   "source": [
    "We've observed a significant improvement in performance! Since the prompt instructs the model to compute the answer multiple times independently, you may notice that the experiment takes slightly longer to run. You can click into the experiement explore to view the independent computations the model performed for each problem.\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "7_KTY0MK5VYs"
   },
   "source": [
    "![Exp 2 Results](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_6.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "YqMgrBcu49dV"
   },
   "source": [
    "![Experiment 2](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_5.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "MS4XCiW4F_-W"
   },
   "source": [
    "# Few Shot CoT Prompting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "qEP_SJS7D4Cr"
   },
   "source": [
    "**Few-shot CoT prompting** enhances reasoning by providing worked examples before asking the model to solve a new problem. By demonstrating step-by-step solutions, the model learns to apply similar logical reasoning to unseen questions.\n",
    "\n",
    "This method leverages **in-context learning**, allowing the model to generalize patterns from the examples.\n",
    "\n",
    " In this final section, we’ll compare Few-Shot CoT against our previous prompts.\n",
    "\n",
    " First, let's construct our prompt by sampling examples from a test dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ds = load_dataset(\"syeddula/math_word_problems\")[\"test\"]\n",
    "few_shot_examples = ds.to_pandas().sample(5)\n",
    "few_shot_examples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "n2KN5URE7i34"
   },
   "source": [
    "We now will construct our final prompt, run the experiement, and view the results. Under the **Prompts tab** in Phoenix, you can track the version history of your prompt and see what random examples were chosen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "few_shot_COT_template = \"\"\"\n",
    "You are an evaluator who outputs the answer to a math word problem. You must always think through the problem logically before providing an answer. Show some of your reasoning.\n",
    "\n",
    "Finally, output the integer answer ONLY on a final new line. In this final answer, be sure not include words, commas, labels, or units and round all decimals answers.\n",
    "\n",
    "Here are some examples of word problems, step by step explanations, and solutions to guide your reasoning:\n",
    "\n",
    "{examples}\n",
    "\"\"\"\n",
    "params = CompletionCreateParamsBase(\n",
    "    model=\"gpt-3.5-turbo\",\n",
    "    temperature=0,\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": few_shot_COT_template.format(examples=few_shot_examples)},\n",
    "        {\"role\": \"user\", \"content\": \"{{Problem}}\"},\n",
    "    ],\n",
    ")\n",
    "\n",
    "few_shot_COT = PhoenixClient().prompts.create(\n",
    "    name=prompt_identifier,\n",
    "    prompt_description=\"Few Shot COT prompt\",\n",
    "    version=PromptVersion.from_openai(params),\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "26qIa_F-9Is6"
   },
   "source": [
    "![Few Shot Prompt](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_8.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def few_shot_COT_prompt(input):\n",
    "    client = OpenAI()\n",
    "    resp = client.chat.completions.create(\n",
    "        **few_shot_COT.format(variables={\"Problem\": input[\"Word Problem\"]})\n",
    "    )\n",
    "    response_text = resp.choices[0].message.content.strip()\n",
    "    lines = response_text.split(\"\\n\")\n",
    "    final_answer = lines[-1].strip()\n",
    "    final_answer = re.sub(r\"^\\*\\*(\\d+)\\*\\*$\", r\"\\1\", final_answer)\n",
    "    return {\"full_response\": response_text, \"final_answer\": final_answer}\n",
    "\n",
    "\n",
    "def evaluate_response(output, expected):\n",
    "    final_answer = output[\"final_answer\"]\n",
    "    if not final_answer.isdigit():\n",
    "        return False\n",
    "    return int(final_answer) == int(expected[\"Answer\"])\n",
    "\n",
    "\n",
    "initial_experiment = await async_client.experiments.run_experiment(\n",
    "    dataset=dataset,\n",
    "    task=few_shot_COT_prompt,\n",
    "    evaluators=[evaluate_response],\n",
    "    experiment_description=\"Few-Shot COT Prompt\",\n",
    "    experiment_name=\"few-shot-cot-prompt\",\n",
    "    experiment_metadata={\"prompt\": \"prompt_id=\" + few_shot_COT.id},\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "lGnjvOBv3kcp"
   },
   "source": [
    "# **Final Results**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Ip-ZlN8a6f1a"
   },
   "source": [
    "After running all of your experiments, you can compare the performance of different prompting techniques. Keep in mind that results may vary due to randomness and the model's non-deterministic behavior.\n",
    "\n",
    "You can review your prompt version history in the **Prompts tab** and explore the **Playground** to iterate further and run additional experiments.\n",
    "\n",
    "To refine and test these prompts against other datasets, experiment with Chain of Thought (CoT) prompting to see its relevance to your specific use cases. With Phoenix, you can seamlessly integrate this process into your workflow using the TypeScript and Python Clients.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "1Fb97M0V7fmg"
   },
   "source": [
    "![Final Run Results](https://storage.googleapis.com/arize-phoenix-assets/assets/images/CoT_Demo_7.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "KWiS2E7W3jNi"
   },
   "source": [
    "From here, you can check out more [examples on Phoenix](https://arize.com/docs/phoenix/notebooks), and if you haven't already, [please give us a star on GitHub!](https://github.com/Arize-ai/phoenix) ⭐️"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
